package pattern;

import pattern.adapter.Adaptee;
import pattern.adapter.Adapter;
import pattern.adapter.Target;
import pattern.observer.Leader;
import pattern.observer.Team;
import pattern.register.Database;
import pattern.register.Factory;
import pattern.register.Register;

public class TestPattern {
	public static void main(String[] args) {
		testObserverPattern();

		testAdapterPattern();

		testRegister();
	}

	static void testObserverPattern() {
		Team teamA = new Team("A");
		Team teamB = new Team("B");
		Team teamC = new Team("C");

		Leader publisher = new Leader();
		publisher.register(teamA);
		publisher.register(teamB);
		publisher.register(teamC);
		publisher.notifyObservers();
	}

	static void testAdapterPattern() {
		Adaptee adaptee = new Adaptee();
		Target target = new Adapter(adaptee);
		target.request();
	}

	static void testRegister() {
		Factory.getDatabase(Factory.MYSQL);
		Factory.getDatabase(Factory.ORACLE);

		Database db1 = Register.get(Factory.MYSQL);
		Database db2 = Register.get(Factory.ORACLE);
		System.out.println(db1.getClass().getSimpleName());
		System.out.println(db2.getClass().getSimpleName());
	}
}
